package com.shuoyue.adven;

import android.app.Activity;
import android.app.Application;

import com.shuoyue.adven.main.appcontrol.DevicesTool;

import java.util.Locale;

import me.jessyan.autosize.AutoSize;
import me.jessyan.autosize.AutoSizeConfig;
import me.jessyan.autosize.onAdaptListener;
import me.jessyan.autosize.utils.LogUtils;

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        initDkPlayer();
        initConstant();
        initDesTool();
        CrashHandler.getInstance().init(getApplicationContext());//初始化崩溃日志
        DevicesTool.setAppKeepLive("com.shuoyue.adven");
    }

    void initConstant() {
    }

    protected void initDkPlayer() {
//        VideoViewManager.setConfig(VideoViewConfig.newBuilder()
//                .setLogEnabled(BuildConfig.DEBUG)//调试的时候请打开日志，方便排错
////                .setPlayerFactory(IjkPlayerFactory.create())
//                .setPlayerFactory(ExoMediaPlayerFactory.create())
////                .setRenderViewFactory(SurfaceRenderViewFactory.create())
////                .setEnableOrientation(true)
////                .setEnableAudioFocus(false)
////                .setScreenScaleType(VideoView.SCREEN_SCALE_MATCH_PARENT)
////                .setAdaptCutout(false)
////                .setPlayOnMobileNetwork(true)
////                .setProgressManager(new ProgressManagerImpl())
//                .build());
    }

    private void initDesTool() {
        AutoSize.initCompatMultiProcess(this);
        AutoSizeConfig.getInstance()
                .setCustomFragment(true)
                .setOnAdaptListener(new onAdaptListener() {
                    @Override
                    public void onAdaptBefore(Object target, Activity activity) {
                        LogUtils.d(String.format(Locale.ENGLISH, "%s onAdaptBefore!", target.getClass().getName()));
                    }

                    @Override
                    public void onAdaptAfter(Object target, Activity activity) {
                        LogUtils.d(String.format(Locale.ENGLISH, "%s onAdaptAfter!", target.getClass().getName()));
                    }
                });
    }

}
